Fallthrough corrections (#538)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Wed, 15 Apr 2020 13:59:39 +0000 (07:59 -0600)
committerGitHub <noreply@github.com>
Wed, 15 Apr 2020 13:59:39 +0000 (07:59 -0600)
* fix an actual bug found by Wimplicit-fallthrough=

* add comments for gcc wrt Wimplicit-fallthrough=

The real fix is the to add the attribute [[fallthrough]];
which was added in c++17.
gcc accepts this, but until c++17 there wasn't
a requirement to ignore unrecognized attributes, so we can
imagine a pre c++17 compiler might choke on it.

dmtlog.cc
g7towin.cc
skytraq.cc
util.cc
xcsv.cc

index 7497eb3b17a27ed8a193eee4a67949618e384cc4..5b27d10db0b3b6eab79b3a5429239c994af48c07 100644 (file)
--- a/dmtlog.cc
+++ b/dmtlog.cc
@@ -586,7 +586,8 @@ inflate_buff(const char* buff, const size_t size, char** out_buff)
 
     switch (res) {
     case Z_NEED_DICT:
-      res = Z_DATA_ERROR;     /* and fall through */
+      res = Z_DATA_ERROR;
+      /* fallthrough */
     case Z_DATA_ERROR:
     case Z_MEM_ERROR:
       (void)inflateEnd(&strm);
index a0fc62cb1cc2a23bd735a915cf8157e13c179bb6..4efcc98db073898d91f83a7ee26e8540b7e03c7b 100644 (file)
@@ -188,7 +188,7 @@ parse_line(char* buff, int index, const char* delimiter, Waypoint* wpt)
       if (strcmp(cin, "1.0e25") == 0) {
         break;
       }
-      /* !!! NO BREAK !!! */
+      /* fallthrough */
     case WPT_cD_OFS + 1:
     case WPT_cB_OFS + 6:
       WAYPT_SET(wpt, temperature, atof(cin));
index fabd379ed5355962f8848c69fd2e238ed83cb0a3..099825268c38ffb047a117a279849606ada3bf9d 100644 (file)
@@ -785,7 +785,7 @@ process_data_item(struct read_state* pst, const item_frame* pitem, int len)
 
   case 0xc:    /* POI item (same structure as full) */
     poi = 1;
-    /* fall through: */
+    /* fallthrough */
 
   case 0x2:    /* Multi HZ item */
     if (len < MULTI_HZ_ITEM_LEN) {
@@ -822,7 +822,7 @@ process_data_item(struct read_state* pst, const item_frame* pitem, int len)
 
   case 0x6:    /* POI item (same structure as full) */
     poi = 1;
-    /* fall through: */
+    /* fallthrough */
 
   case 0x4:    /* full item */
     if (len < FULL_ITEM_LEN) {
diff --git a/util.cc b/util.cc
index a0c6922d4eacb2ad26b746b22089e855e2458026..df16bd08fa74276366968d294c1d64edd8206083 100644 (file)
--- a/util.cc
+++ b/util.cc
@@ -483,6 +483,7 @@ str_match(const char* str, const char* match)
         return 0;  /* incomplete escape sequence */
       }
     /* pass-through next character */
+    /* fallthrough */
 
     default:
       if (*m != *s) {
diff --git a/xcsv.cc b/xcsv.cc
index 4fffd7b9fcbf68b43922d2da41c6e5d336d1ab44..c404fee78ecce3a513e1e4d786152d51d0912007 100644 (file)
--- a/xcsv.cc
+++ b/xcsv.cc
@@ -1522,6 +1522,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
       garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
       buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_facility(gmsd, "")));
     }
+    break;
     case XT_EMAIL: {
       garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
       buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_email(gmsd, "")));